<?php
class accountclassModel extends model
{
    public function create()
    {
        try{
            $accountClass = fixer::input('post')
                ->specialchars('name')->get();
            $this->dao->insert('account_class')->data($accountClass)
                ->batchCheck('name', 'notempty')->exec();
            return $this->dao->lastInsertID();
        } catch (Exception $e) {
            var_dump($e->getMessage());
        }
    }
    public function delete($id, $table = null)
    {
        return $this->dao->delete()->from("account_class")->where('id')->eq($id)->exec();
    }
    public function getList($pager = null)
    {
        return $this->dao->select("*")
            ->from('account_class')
            ->orderBy('type asc')
            ->page($pager)
            ->fetchAll();
    }
    public function getById($type)
    {
        return $this->dao->select("*")
            ->from('account_class')
            ->where('type')->eq($type)
            ->exec();
    }
    public function update($type)
    {
        $accountClass = fixer::input('post')
            ->specialchars('type, name')
            ->get();
        return $this->dao->update('account_class')
            ->data($accountClass)
            ->where('type')->eq($type)
            ->batchCheck('type, name', 'notempty')
            ->exec();
    }
}